import com.huang.pojo.Student;
import com.huang.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Mytest {
    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
        Student student = (Student) context.getBean("StudentName");
        System.out.println(student);
        /*
        Student{name='黄天',
        address=Address{address='河南新乡'},
        books=[红楼梦, 西游记, 水浒传, 三国演义],
        hobbys=[听歌, 吃饭, 看电影, 打游戏],
        card={银行卡=20191514110, 身份证=411723},
        games=[王者荣耀, 英雄联盟, 皇室战争, 部落冲突],
        wife='null',
        info={学号=201915141118, 性别=男, 姓名=黄天}}
        */
    }

    @Test
    public void test() {
        ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
        User user = context.getBean("User", User.class);
        System.out.println(user);
        User user2 = context.getBean("User2", User.class);
        User user3 = context.getBean("User2", User.class);
        System.out.println(user2);
        //scope="prototype"-》false（每次从容器中get都会产生新对象）， scope="singleton"-》true（默认模式）
        //request，session，application，websocket只能在web中使用
        System.out.println(user3 == user2);
    }
}
